package stu.info.student.info.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import stu.info.student.info.entity
        .Admin;
import stu.info.student.info.mapper.adminMapper;

import java.util.List;

@Slf4j
@Api(tags ="宿工管理模块")
@RestController
@RequestMapping("/admin")
public class adminController {
      @Autowired
    private adminMapper adminMapper;

      @ApiOperation("添加宿工管理员")
      @PostMapping("/add")
      int addAdmin(@RequestBody Admin admin)
      {
          adminMapper.insert(admin);
          log.debug("添加成功>>>{}",admin);
          return 200;
      }

    @ApiOperation("删除宿工管理员")
    @PostMapping("/delete")
    int deleteAdmin(Long ano)
    {
        adminMapper.deleteById(ano);
        log.debug("删除id为{}的宿管员工成功...>>>",ano);
        return 200;
    }

    @ApiOperation("查询宿工管理员")
    @PostMapping("/select")
    List<Admin> getAdmin()
    {
        return adminMapper.select();
    }

    @ApiOperation("修改宿工管理员信息")
    @PostMapping("/update")
    int updateAdmin(@RequestBody Admin admin)
    {
        adminMapper.updateById(admin);
        log.debug("修改id为{}的宿管员工成功...>>>",admin.getAno());
        return 200;
    }
}
